package com.ttg.model.pojo;


import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ttg.common.constant.UNLExportable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * 银行商户信息表实体类
 * @author zhy
 * @date 2024/04/10 11:26
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "tbl_bank_public_primitive")
public class BankPublicPrimitive implements UNLExportable, Serializable {


    private static final long serialVersionUID = -3420925675209744480L;
    /**
     * id
     */
    @TableId(value = "id" , type = IdType.AUTO)
    private Long id;

    /**
     * 商户编号
     */
    @TableField(value = "mct_no")
    private String mctNo;


    /**
     * 商户名称
     */
    @TableField(value = "mct_name")
    private String mctName;


    /**
     * 所属行业
     */
    @TableField(value = "mct_industry")
    private String mctIndustry;
    /**
     * 所属一级行业
     */
    @TableField(value = "mct_cls_id")
    private String mctClsId;


    /**
     * 所属地区
     */
    @TableField(value = "mct_address")
    private String mctAddress;


    /**
     * 注册年限
     */
    @TableField(value = "mct_register_years")
    private Integer mctRegisterYears;


    /**
     * 从业年限
     */
    @TableField(value = "mct_practise_years")
    private Integer mctPractiseYears;


    /**
     * 法人姓名
     */
    @TableField(value = "mct_legal_person_name")
    private String mctLegalPersonName;


    /**
     * 身份证号
     */
    @TableField(value = "mct_id_number")
    private String mctIdNumber;


    /**
     * 法人客户号
     */
    @TableField(value = "mct_boss_cst_id")
    private String mctBossCstId;


    /**
     * 结算账号
     */
    @TableField(value = "mct_settlement_bank_account")
    private String mctSettlementBankAccount;


    /**
     * 账户状态
     */
    @TableField(value = "mct_account_status")
    private String mctAccountStatus;


    /**
     * 开户行号
     */
    @TableField(value = "mct_opening_bank")
    private String mctOpeningBank;

    /**
     * 开户行名称
     */
    @TableField(value = "mct_opening_bank_name")
    private String mctOpeningBankName;


    /**
     * 开户时间
     */
    @TableField(value = "mct_account_opening_time")
    private LocalDate mctAccountOpeningTime;

    /**
     * 注册时间
     */
    @TableField(value = "mct_reg_time")
    private LocalDate mctRegTime;
    /**
     * 从业时间
     */
    @TableField(value = "mct_practise_time")
    private LocalDate mctPractiseTime;

    /**
     * 注册方式(0=非渠道，1=渠道)
     */
    @TableField(value = "mct_reg_type")
    private Integer mctRegType;


    /**
     * 注册渠道编号
     */
    @TableField(value = "mct_chl_id")
    private Long mctChlId;

    /**
     * 所属机构
     */
    @TableField(value = "mct_agent_no")
    private String mctAgentNo;

    /**
     * 所属二级机构
     */
    @TableField(value = "mct_sub_agent_no")
    private String mctSubAgentNo;

    /**
     * 会员等级
     */
    @TableField(value = "mct_grade")
    private Integer mctGrade;

    /**
     * 积分余额
     */
    @TableField(value = "mct_integration_amount")
    private Long mctIntegrationAmount;


    /**
     * 上期成长值
     */
//    @TableField(value = "mct_ago_grow")
//    private Long mctAgoGrow;
//
    /**
     * 当前成长值
     */
//    @TableField(value = "mct_now_grow")
//    private Long mctNowGrow;

    /**
     * 等级有效期起始时间
     */
    @TableField(value = "mct_grade_start_date")
    private LocalDate mctGradeStartDate;

    /**
     * 会员等级有效期
     */
    @TableField(value = "mct_grade_date")
    private LocalDate mctGradeDate;

    /**
     * 会员状态 0正常 1冻结
     */
    @TableField(value = "mct_status")
    private Integer mctStatus;

    /**
     * 结算账户的月均余额
     */
    @TableField(value = "mct_settlement_bank_account_month_average")
    private BigDecimal mctSettlementBankAccountMonthAverage;

    /**
     * 结算账户的月均余额
     */
    @TableField(value = "mct_real_settlement_bank_account_month_average")
    private BigDecimal mctRealSettlementBankAccountMonthAverage;


    /**
     * 有效交易月份数
     */
    @TableField(value = "mct_transaction_month_number")
    private Integer mctTransactionMonthNumber;

    /**
     * 银行机构号
     */
    @TableField(value = "mct_sc_agent_no")
    private String mctScAgentNo;
    /**
     * 客户经理名称
     */
    @TableField(value = "mct_manager_name")
    private String mctManagerName;



    /**
     * 更新时间
     */
    @TableField(value = "update_time")
    private LocalDate updateTime;

    /**
     * 等级变化
     */
    @TableField(value = "mct_grade_change")
    private Integer mctGradeChange;
    @Override
    public String toFieIds(){

        List<String> fieIds = Arrays.asList(
                Objects.isNull(id)?"":id.toString(),
                Objects.isNull(mctNo)?"":mctNo.toString(),
                Objects.isNull(mctName)?"":mctName.toString(),
                Objects.isNull(mctIndustry)?"":mctIndustry.toString(),
                Objects.isNull(mctClsId)?"":mctClsId.toString(),
                Objects.isNull(mctAddress)?"":mctAddress.toString(),
                Objects.isNull(mctRegisterYears)?"":mctRegisterYears.toString(),
                Objects.isNull(mctPractiseYears)?"":mctPractiseYears.toString(),
                Objects.isNull(mctLegalPersonName)?"":mctLegalPersonName.toString(),
                Objects.isNull(mctIdNumber)?"":mctIdNumber.toString(),
                Objects.isNull(mctBossCstId)?"":mctBossCstId.toString(),
                Objects.isNull(mctSettlementBankAccount)?"":mctSettlementBankAccount.toString(),
                Objects.isNull(mctAccountStatus)?"":mctAccountStatus.toString(),
                Objects.isNull(mctOpeningBank)?"":mctOpeningBank.toString(),
                Objects.isNull(mctOpeningBankName)?"":mctOpeningBankName.toString(),
                Objects.isNull(mctAccountOpeningTime)?"":mctAccountOpeningTime.toString(),
                Objects.isNull(mctRegTime)?"":mctRegTime.toString(),
                Objects.isNull(mctPractiseTime)?"":mctPractiseTime.toString(),
                Objects.isNull(mctRegType)?"":mctRegType.toString(),
                Objects.isNull(mctChlId)?"":mctChlId.toString(),
                Objects.isNull(mctAgentNo)?"":mctAgentNo.toString(),
                Objects.isNull(mctSubAgentNo)?"":mctSubAgentNo.toString(),
                Objects.isNull(mctGrade)?"":mctGrade.toString(),
                Objects.isNull(mctIntegrationAmount)?"":mctIntegrationAmount.toString(),
                Objects.isNull(mctGradeStartDate)?"":mctGradeStartDate.toString(),
                Objects.isNull(mctGradeDate)?"":mctGradeDate.toString(),
                Objects.isNull(mctStatus)?"":mctStatus.toString(),
                Objects.isNull(mctSettlementBankAccountMonthAverage)?"":mctSettlementBankAccountMonthAverage.toString(),
                Objects.isNull(mctRealSettlementBankAccountMonthAverage)?"":mctRealSettlementBankAccountMonthAverage.toString(),
                Objects.isNull(mctTransactionMonthNumber)?"":mctTransactionMonthNumber.toString(),
                Objects.isNull(mctScAgentNo)?"":mctScAgentNo.toString(),
                Objects.isNull(mctManagerName)?"":mctManagerName.toString(),
                Objects.isNull(updateTime)?"":updateTime.toString(),
                Objects.isNull(mctGradeChange)?"":mctGradeChange.toString()
        );
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < fieIds.size(); i++) {
            String fieId = fieIds.get(i);
            if (fieId.contains("|")||fieId.contains("\"")){
                fieId="\""+fieId.replace("\"","\"\"")+"\"";
            }
            sb.append(fieId);
            if (i<fieIds.size()-1){
                sb.append("|");
            }
        }
        return sb.toString();
    }
}
